﻿Imports System
Imports System.Drawing

Namespace System.Workflow.ComponentModel.Design
    Public Class ConnectorHitTestInfo
        Inherits HitTestInfo
        ' Methods
        Public Sub New(ByVal compositeActivityDesigner As CompositeActivityDesigner, ByVal flags As HitTestLocations, ByVal connector As Integer)
            MyBase.New(compositeActivityDesigner, flags)
            If (Me.connector < 0) Then
                Throw New ArgumentException(SR.GetString("Error_InvalidConnectorValue"), "connector")
            End If
            Me.connector = connector
        End Sub

        Public Overrides Function Equals(ByVal obj As Object) As Boolean
            Dim info As ConnectorHitTestInfo = [TryCast](obj,ConnectorHitTestInfo)
            Return (((Not info Is Nothing) AndAlso (info.AssociatedDesigner Is MyBase.AssociatedDesigner)) AndAlso ((info.HitLocation = MyBase.HitLocation) AndAlso (info.MapToIndex = Me.MapToIndex)))
        End Function

        Public Overrides Function GetHashCode() As Integer
            Return ((MyBase.GetHashCode Xor If((Not MyBase.AssociatedDesigner Is Nothing), MyBase.AssociatedDesigner.GetHashCode, 0)) Xor Me.MapToIndex.GetHashCode)
        End Function

        Public Overrides Function MapToIndex() As Integer
            Return Me.connector
        End Function


        ' Properties
        Public Overrides ReadOnly Property Bounds As Rectangle
            Get
                Dim associatedDesigner As SequentialActivityDesigner = [TryCast](MyBase.AssociatedDesigner,SequentialActivityDesigner)
                If ((Not associatedDesigner Is Nothing) AndAlso associatedDesigner.Expanded) Then
                    Dim connectors As Rectangle() = associatedDesigner.GetConnectors
                    If (connectors.Length > 0) Then
                        Return connectors(Me.connector)
                    End If
                End If
                Return Rectangle.Empty
            End Get
        End Property

        Public Overrides ReadOnly Property SelectableObject As Object
            Get
                Return Me
            End Get
        End Property


        ' Fields
        Private connector As Integer
    End Class
End Namespace

